﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CompanyManageModel;
using CompanyManageRepositoryIServices;
using CompanyManageRepositoryServices;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace CompanyManageAPI.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class EmployeeController : ControllerBase
    {
        readonly IEmployeeServices _EmployeeServices;

        public EmployeeController(IEmployeeServices EmployeeServices)
        {
            _EmployeeServices = EmployeeServices;
        }

        [HttpPost()]
        public void Add(Employee employee)
        {
            //IEmployeeServices employeeServices = new EmployeeServices();
            try {
                _EmployeeServices.Add(employee);
            }
            catch (Exception e)
            {

            }

        }

        [HttpGet()]
        public void Delete(int id)
        {
            //IEmployeeServices employeeServices = new EmployeeServices();
            _EmployeeServices.DeleteById(id);

        }

        [HttpPost()]
        public void Update(Employee employee)
        {
            //IEmployeeServices employeeServices = new EmployeeServices();
            _EmployeeServices.Update(employee);

        }

        [HttpGet()]
        public Task<List<Employee>> GetAll()
        {
            //IEmployeeServices employeeServices = new EmployeeServices();
            return _EmployeeServices.Query();

        }


        [HttpGet()]
        public Task<List<Result>> GetTitleCount()
        {
            //IEmployeeServices employeeServices = new EmployeeServices();
            return _EmployeeServices.GetTitleCount();


        }


        

    }
}